<template>
  <div class="main">
    <nav-bar class="home-nav">
      <div class="left" slot="left" @click="goBack">
        <van-icon name="arrow-left" size="24"/>
      </div>
      <div slot="center">阶段选择</div>
    </nav-bar>

  <div v-if="!isNoData" class="orign">
    <div class="step">
      <div class="box" v-for="(item,index) in stages" :key="index" >
        <div class="left_item">
          <div :class="(index+1)%2==0?'one hidden':'one'" @click="toList(item)">{{item.name}}</div>
          <div :class="(index+1)%2==0?'circle_left hidden':'circle_left'">{{'0'+(index+1)}}</div>
        </div>
        <div class="right_item">
          <div :class="(index+1)%2==0?'two':'two hidden'" @click="toList(item)">{{item.name}}</div>
          <div :class="(index+1)%2==0?'circle_right':'circle_right hidden'">{{'0'+(index+1)}}</div>
        </div>
        <!--<div class="hidden_last"></div>-->
      </div>

    </div>
  </div>
    <div v-else><no-data></no-data></div>
  </div>
</template>

<script>
  import NavBar from "@/components/common/navbar/NavBar";
  import noData from "@/components/content/nodata";
  export default {
    name: "Orign",
    components: {
      NavBar,
      noData
    },
    data(){
      return{
        isNoData:false,
        bid:'',
        pid: '',
        stages:[],//阶段
      }
    },
    created(){
      this.base_id = this.$route.query.base_id;
      this.bid = this.$route.query.bid;
      this.pid = this.$route.query.pid;
      this.getStageList();
    },
    mounted(){

    },
    methods:{
      getStageList() {
        let that = this;
        console.log('pid', that.pid)
        that.$http.get('/api/MobileAadminApi/getStageList', {pid: that.pid}, r => {
          console.log('阶段', r)
          that.stages = r.data;
          if(that.stages.length == 0){
            that.isNoData = true
          }
        })
      },

      toList(e){
        console.log(e)
        this.$router.push({path:'/sensor_index',query:{base_id:this.base_id, bid:this.bid, pid:this.pid, sid:e.id}})
      },

      goBack() {
        this.$router.go(-1);
      },
    }
  }
</script>

<style scoped>
  .orign{
    /*height: calc(100vh - 44px - 49px - 180px - 55px);*/
    box-sizing: border-box;
    padding-bottom: 0.2rem;
    position: relative;
  }
  .step{
    background: white;
    border-radius: 0.12rem;
    height: 13rem;
    box-sizing: border-box;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    padding-left: 0.44rem;
    padding-right: 0.44rem;
    position: relative;
  }

  .box{
    width: 100%;
    height: 1.5rem;
    display: flex;
    flex-direction: row;
  }
  .box:last-child .left_item{
    border-right: white solid 0.08rem;
  }
  .box:last-child .right_item{
    border-left: white solid 0.08rem;
  }
  .hidden_last{
    position: absolute;
    height: 1.2rem;
    width: 0.3rem;
    background:#ffffff;
    /*background:red;*/
    left: 48%;
    top: 39%;
    z-index: 3;
    /*display: none;*/

  }
  .left_item{
    flex: 1;
    box-sizing: border-box;
    border-right: var(--color-tint) solid 0.08rem;
    position: relative;
  }
  .circle_left{
    position: absolute;
    height: 0.5rem;
    width: 0.5rem;
    background: var(--color-tint);
    font-size: 0.3rem;
    top: -4%;
    color: white;
    text-align: center;
    line-height: 0.5rem;
    left: 95%;
    border-radius: 50%;
    z-index: 4;
  }
  .right_item{
    flex: 1;
    box-sizing: border-box;
    box-sizing: border-box;
    border-left: var(--color-tint) solid 0.08rem;
    position: relative;
  }
  .circle_right{
    border-radius: 50%;
    position: absolute;
    height: 0.5rem;
    width: 0.5rem;
    background: var(--color-tint);
    font-size: 0.3rem;
    top: -4%;
    color: white;
    text-align: center;
    line-height: 0.5rem;
    left: -10%;
    z-index: 4;
  }

  .one{
    position: absolute;
    right: 20px;
    top: -6px;
    height: 0.8rem;
    width: 2.76rem;
    background-image: url('../../../assets/images/step_left.png');
    background-size: cover;
    background-repeat: no-repeat;
    color: black;
    font-family:"Adobe 黑体 Std R" ;
    font-size: 0.34rem;
    line-height: 0.8rem;
    text-align: center;
  }

  .two{
    position: absolute;
    left: 22px;
    top: -6px;
    height: 0.8rem;
    width: 2.76rem;
    background-image: url('../../../assets/images/step_right.png');
    background-size: cover;
    background-repeat: no-repeat;
    color: black;
    font-family:"Adobe 黑体 Std R" ;
    font-size: 0.34rem;
    line-height: 0.8rem;
    text-align: center;
  }
  .hidden{
    display: none;
  }

</style>
